package com.bawei.module_mine.audit

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import androidx.viewpager2.widget.ViewPager2
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.lib_common.Router
import com.bawei.lib_common.base.BaseActivity
import com.bawei.module_mine.R
import com.bawei.module_mine.adapter.AuditFragmentAdapter
import com.bawei.module_mine.adapter.MineAdapter
import com.bawei.module_mine.databinding.ActivityAuditBinding
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = Router.Ui.AuditActivity)
class AuditActivity : BaseActivity<AuditViewModel,ActivityAuditBinding>() {
    override val mLayoutResId: Int
        get() = R.layout.activity_audit
    override val mViewModel: AuditViewModel by viewModels()
    private val mAuditFragmentAdapter: AuditFragmentAdapter by lazy {
        AuditFragmentAdapter(this)
    }

    override fun initView() {
        mBinding.itemBar.toolbarTitle.text = "审核管理"
    }

    override fun initListener() {

    }

    override fun initData() {

        // 1. 初始化 ViewPager2 和 适配器
        mBinding.viewPager.adapter = mAuditFragmentAdapter
        // 2. 初始化 TabLayout 并绑定 ViewPager2
        val tabLayout = findViewById<TabLayout>(R.id.tab_layout)
        TabLayoutMediator(tabLayout, mBinding.viewPager) { tab, position ->
            // 设置每个标签的文本
            tab.text = mAuditFragmentAdapter.fragmentTitleList[position]
        }.attach()

        // 3. 可选：监听标签切换事件
        tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
            override fun onTabSelected(tab: TabLayout.Tab) {
                // 选中时的逻辑（可选）
            }

            override fun onTabUnselected(tab: TabLayout.Tab) {}
            override fun onTabReselected(tab: TabLayout.Tab) {}
        })
    }
}